﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_AttackPacket : ServerBasePacket
    {
        private static Logger _log = Logger.getLogger( typeof( S_AttackPacket ).FullName );

        private byte[] _byte = null;

        public S_AttackPacket( L1PcInstance pc, int objid, int type )
        {
            _log.info( Environment.StackTrace );
            buildpacket( pc, objid, type );
        }

        private void buildpacket( L1PcInstance pc, int objid, int type )
        {
            writeC( Opcodes.S_OPCODE_ATTACKPACKET );
            writeC( type );
            writeD( pc.getId() );
            writeD( objid );
            writeC( 0x01 ); // damage
            writeC( pc.getHeading() );
            writeH( 0x0000 ); // target x
            writeH( 0x0000 ); // target y
            writeC( 0x00 ); // 0x00:none 0x04:Claw 0x08:CounterMirror
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }

            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_AttackPacket";
        }
    }
}